// 微信Token - Hotel
import { DataTypes, UUIDV4 } from 'sequelize';
import { MySqlModel, getSequelize } from '../db';

class WeixinAccessToken extends MySqlModel {

}

WeixinAccessToken.init({
  id: {
    type: DataTypes.UUID, unique: 'id', allowNull: false, defaultValue: UUIDV4, validate: { isUUID: 4 }, primaryKey: true, comment: '主键'
  },
  hotel_id: {
    type: DataTypes.UUID, unique: 'hotel_id_appid', allowNull: false, validate: { isUUID: 4 }, comment: '主体'
  },
  appid: {
    type: DataTypes.STRING(50), unique: 'hotel_id_appid', allowNull: false, comment: '小程序appid'
  },
  access_token: {
    type: DataTypes.STRING(512), allowNull: false, comment: 'token'
  },
  expired_at: {
    type: DataTypes.DATE, allowNull: false, comment: '失效时间'
  }
}, {
  sequelize: getSequelize(),
  tableName: 'weixin_access_token',
  comment: '微信接口调用凭证'
});

export default WeixinAccessToken;
